#ifndef __SW_TIM_H
#define __SW_TIM_H

#include <stdbool.h>

#include "main.h"
#include "logout.h"

typedef enum
{
    TIMER_RUN_STOP,
		TIMER_RUN_DELAY,
		TIMER_RUN_RUNING,
    TIMER_RUN_TIMOUT,
} app_timer_run_status_t;

typedef enum
{
    APP_TIMER_MODE_SINGLE_SHOT,                 /**< The timer will expire only once. */
    APP_TIMER_MODE_REPEATED                     /**< The timer will restart each time it expires. */
} app_timer_mode_t;


typedef void (*app_timer_timeout_handler_t)(void * p_context);

typedef struct
{
		uint32_t                    	next_time; 
    uint32_t                    	interval;  
		uint32_t                    	start_delay; 
    app_timer_mode_t              timer_mode; 
    app_timer_timeout_handler_t 	timeout_handler;      
    app_timer_run_status_t        run_status;       
} app_timer_t;

typedef app_timer_t * app_timer_id_t;



app_timer_id_t app_timer_create(	app_timer_mode_t            mode,
																	app_timer_timeout_handler_t timeout_handler);
void app_timer_start(app_timer_id_t p_timer, uint32_t interval, uint32_t start_delay);

void app_timer_stop(app_timer_id_t p_timer);

void app_timer_schedule(void);

#endif 
